package com.test;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class sort1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] arr = new int[7];
        System.out.println("请输入7个要排序的数字");
        for (int i = 0; i < arr.length; i++) {
            arr[i] = scanner.nextInt();
        }
        System.out.println("排序前的数组为：" + Arrays.toString(arr));
        for (int i = 0; i < arr.length-1; i++){
            for (int j = 0; j < arr.length-i-1; j++){
                if (arr[j] > arr[j+1]){
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
        }
        System.out.println("排序后的数组为：" + Arrays.toString(arr));
    }
}
